package school.valon.persistence.dao.impl;

import school.valon.persistence.dao.StaffDao;
import school.valon.persistence.dao.base.impl.GenericDaoImpl;
import school.valon.persistence.pojo.Staff;
import school.valon.persistence.pojo.StaffAttendance;
import school.valon.persistence.pojo.StaffFunction;

public class StaffDaoImpl extends GenericDaoImpl<Staff, Integer> implements StaffDao {
	public StaffFunction findStaffFunctionById(Integer staffFunctionId) {
		return em.find(StaffFunction.class, staffFunctionId);
	}

	public StaffAttendance findStaffAtendance(Integer staffAttendanceId) {
		return em.find(StaffAttendance.class, staffAttendanceId);
	}

	public StaffAttendance createStaffAtendance(StaffAttendance staffAttendance) {
		em.persist(staffAttendance);
		return staffAttendance;
	}

	public StaffAttendance updateStaffAtendance(StaffAttendance staffAttendance) {
		return em.merge(staffAttendance);
	}

	public void deleteStaffAttendance(Integer staffAtendanceId) {
    	em.createNamedQuery("StaffAttendance.deleteById")
			.setParameter("P1", staffAtendanceId).executeUpdate();
	}
}

